<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
    <script src="../plugins/nprogress/nprogress.js"></script>
    <link rel="stylesheet" href="../plugins/nprogress/nprogress.css">
    <!--<link rel="stylesheet" href="https://unpkg.com/element-ui@2.11.0/lib/theme-chalk/index.css">-->
    <style type="text/css">
        .el-main {
            position: absolute;
            top: 70px;
            bottom: 0px;
            left: 200px;
            right: 10px;
            padding: 0;
        }
    </style>

</head>
<!--<body class="hold-transition skin-purple sidebar-mini">-->
<!--<div id="app">-->
    <!--<el-container>-->
        <!--<el-header class="main-header" style="height:70px;">-->
            <!--<nav class="navbar navbar-static-top" :class=''>-->
                <!--&lt;!&ndash; Logo &ndash;&gt;-->
                <!--<a href="#" class="logo" style="text-align:center">-->
                    <!--<span class="logo-lg"><img src="../img/logo.png"></span>-->
                <!--</a>-->
                <!--<div class="right-menu">-->
                    <!--<span class="help"><i class="fa fa-exclamation-circle" aria-hidden="true"></i>帮助</span>-->
                    <!--<el-dropdown class="avatar-container right-menu-item" trigger="click">-->
                        <!--<div class="avatar-wrapper">-->
                            <!--<img src="../img/user2-160x160.jpg" class="user-avatar">-->
                            <!--{{username}}-->
                        <!--</div>-->
                        <!--<el-dropdown-menu slot="dropdown">-->
                            <!--<el-dropdown-item divided>-->
                                <!--<span style="display:block;" @click="handleEdit()">修改密码</span>-->
                            <!--</el-dropdown-item>-->
                            <!--<el-dropdown-item divided>-->
                                        <!--<span style="display:block;">-->
                                            <!--<a href="/logout.do">退出</a>-->
                                        <!--</span>-->
                            <!--</el-dropdown-item>-->
                        <!--</el-dropdown-menu>-->
                    <!--</el-dropdown>-->
                <!--</div>-->
            <!--</nav>-->
        <!--</el-header>-->
        <!--<el-container>-->
            <!--<el-aside width="200px">-->
                <!--<el-menu>-->
                    <!--<el-submenu v-for="menu in menuList" :index="menu.path">-->
                        <!--<template slot="title">-->
                            <!--<i class="fa" :class="menu.icon"></i>-->
                            <!--{{menu.title}}-->
                        <!--</template>-->
                        <!--<template v-for="child in menu.children">-->
                            <!--<el-menu-item :index="child.path">-->
                                <!--<a :href="child.linkUrl" target="right">{{child.title}}</a>-->
                            <!--</el-menu-item>-->
                        <!--</template>-->
                    <!--</el-submenu>-->
                <!--</el-menu>-->
            <!--</el-aside>-->
            <!--<el-container>-->
                <!--<iframe name="right" class="el-main" src="checkitem.html" width="100%" height="850px"-->
                        <!--frameborder="0"></iframe>-->
            <!--</el-container>-->
        <!--</el-container>-->
    <!--</el-container>-->

    <!-- 编辑标签弹层 -->


<!--</div>-->
<!--</body>-->

<body class="hold-transition skin-purple sidebar-mini">
<div id="app">
    <el-container>
        <el-header  class="main-header" style="height:70px;">
            <nav class="navbar navbar-static-top" :class=''>
                <!-- Logo -->
                <a href="#" class="logo" style="text-align:center">
                    <span class="logo-lg"><img src="../img/logo.png"></span>
                </a>
                <div class="right-menu">
                    <span class="help"><i class="fa fa-exclamation-circle" aria-hidden="true"></i>帮助</span>
                    <el-dropdown class="avatar-container right-menu-item" trigger="click">
                        <div class="avatar-wrapper">
                            <!--<img src="../img/user2-160x160.jpg"  class="user-avatar">-->
                            <img v-if="UserImg" :src="UserImg" class="avatar">
                            {{username}}
                        </div>
                        <el-dropdown-menu slot="dropdown">

                            <el-dropdown-item divided >
                                <div v-for="username1 in quanxian">
                                    <span @click="fun(username1.id)">{{username1.name}}</span>
                                </div>
                            </el-dropdown-item>

                            <el-dropdown-item divided>

                                <el-upload
                                        class="avatar-uploader"
                                        action="/user/upload.do"
                                        :auto-upload="autoUpload"
                                        name="imgFile"
                                        :show-file-list="false"
                                        :on-success="handleAvatarSuccess"
                                        :before-upload="beforeAvatarUpload">
                                    <!--<img v-if="UserImg" :src="UserImg" class="avatar">-->
                                    <!--<i v-else class="el-icon-plus avatar-uploader-icon"></i>-->
                                    <span style="display:block;">修改头像</span>

                                </el-upload>

                            </el-dropdown-item>
                            <el-dropdown-item divided>
                                <span style="display:block;" @click="handleEdit()">修改密码</span>
                            </el-dropdown-item>
                            <el-dropdown-item divided>
                                        <span style="display:block;">
                                            <a href="/logout.do">退出</a>
                                        </span>
                            </el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                </div>

            </nav>
        </el-header>
        <el-container>
            <el-aside width="200px">
                <el-menu>
                    <el-submenu v-for="menu in menuList" :index="menu.path">
                        <template slot="title">
                            <i class="fa" :class="menu.icon"></i>
                            {{menu.title}}
                        </template>
                        <template v-for="child in menu.children">
                            <el-menu-item :index="child.path">
                                <a :href="child.linkUrl" target="right">{{child.title}}</a>
                            </el-menu-item>
                        </template>
                    </el-submenu>
                </el-menu>
            </el-aside>
            <el-container>
                <iframe name="right" class="el-main" src="checkitem.html" width="100%" height="850px" frameborder="0"></iframe>
            </el-container>
        </el-container>
    </el-container>

    <div class="add-form">
        <el-dialog title="修改密码" :visible.sync="dialogFormVisibleEditPassword">
            <template>
                <el-tabs type="card">
                    <el-tab-pane label="Edit">
                        <el-form label-position="right" label-width="100px" center>
                            <el-row>
                                <el-col :span="12">
                                    <el-form-item label="用户名">

                                        <el-input
                                                v-model="formData.username"
                                                :disabled="true">
                                        </el-input>

                                    </el-form-item>

                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="12">
                                    <el-form-item label="旧密码">

                                        <el-input
                                                placeholder="请输入旧密码"
                                                v-model="formData.oldPassword"
                                                show-password>
                                        </el-input>

                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="12">
                                    <el-form-item label="新密码">

                                        <el-input
                                                placeholder="请输入新密码"
                                                v-model="formData.newPassword"
                                                show-password>
                                        </el-input>


                                    </el-form-item>
                                </el-col>
                            </el-row>

                        </el-form>
                    </el-tab-pane>
                    </el-tab-pane>
                </el-tabs>
            </template>

            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisibleEditPassword = false">取消</el-button>
                <el-button type="primary" @click="edit()">确定</el-button>
            </div>

        </el-dialog>
    </div>

    <div class="add-form">
        <el-dialog title="修改密码" :visible.sync="dialogFormVisibleEditPassword">
            <template>
                <el-tabs type="card">
                    <el-tab-pane label="Edit">
                        <el-form label-position="right" label-width="100px" center>
                            <el-row>
                                <el-col :span="12">
                                    <el-form-item label="用户名">

                                        <el-input
                                                v-model="formData.username"
                                                :disabled="true">
                                        </el-input>

                                    </el-form-item>

                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="12">
                                    <el-form-item label="旧密码">

                                        <el-input
                                                placeholder="请输入旧密码"
                                                v-model="formData.oldPassword"
                                                show-password>
                                        </el-input>

                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="12">
                                    <el-form-item label="新密码">

                                        <el-input
                                                type="password"
                                                placeholder="请输入新密码"
                                                v-model="formData.newPassword"
                                                password>
                                        </el-input>


                                    </el-form-item>
                                </el-col>
                            </el-row>

                        </el-form>
                    </el-tab-pane>
                    </el-tab-pane>
                </el-tabs>
            </template>

            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisibleEditPassword = false">取消</el-button>
                <el-button type="primary" @click="edit()">确定</el-button>
            </div>

        </el-dialog>
    </div>
</div>
</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script>
    new Vue({
        el: '#app',
        data: {
            autoUpload:true,//自动上传
            dialogFormVisibleEditPassword: false,
            formData: {
                newPassword: null
            },
            UserImg:"",
            menuList: [
                {
                    "path": "1",
                    "title": "工作台",
                    "icon": "fa-dashboard",
                    "children": [{
                        "path": "/1-1",
                        "title": "角色管理",
                        "linkUrl": "role_management.html",
                        "children": []
                    },
                        {
                            "path": "/1-2",
                            "title": "用户管理",
                            "linkUrl": "user.html",
                            "children": []
                        },
                        {
                            "path": "/1-3",
                            "title": "菜单管理",
                            "linkUrl": "menu-manage.html",
                            "children": []
                        },
                    ]
                },
                {
                    "path": "2",
                    "title": "会员管理",
                    "icon": "fa-user-md",
                    "children": [
                        {
                            "path": "/2-1",
                            "title": "体检上传",
                            "children": []
                        },
                        {
                            "path": "/2-2",
                            "title": "会员统计",
                            "linkUrl": "all-item-list.html",
                            "children": []
                        },
                    ]
                },
                {
                    "path": "3",
                    "title": "预约管理",
                    "icon": "fa-tty",
                    "children": [
                        {
                            "path": "/3-1",
                            "title": "预约列表",
                            "linkUrl": "ordersettinglist.html",
                            "children": []
                        },
                        {
                            "path": "/3-2",
                            "title": "预约设置",
                            "linkUrl": "ordersetting.html",
                            "children": []
                        },
                        {
                            "path": "/3-3",
                            "title": "套餐管理",
                            "linkUrl": "setmeal.html",
                            "children": []
                        },
                        {
                            "path": "/3-4",
                            "title": "检查组管理",
                            "linkUrl": "checkgroup.html",
                            "children": []
                        },
                        {
                            "path": "/3-5",
                            "title": "检查项管理",
                            "linkUrl": "checkitem.html",
                            "children": []
                        },
                    ]
                },
                {
                    "path": "4",
                    "title": "健康评估",
                    "icon": "fa-stethoscope",
                    "children": [
                        {
                            "path": "/4-1",
                            "title": "中医体质辨识",
                            "linkUrl": "all-medical-list.html",
                            "children": []
                        },
                    ]
                },
                {
                    "path": "5",     //菜单项所对应的路由路径
                    "title": "统计分析",     //菜单项名称
                    "icon": "fa-heartbeat",
                    "children": [//是否有子菜单，若没有，则为[]
                        {
                            "path": "/5-1",
                            "title": "工作量统计",
                            "linkUrl": "all-medical-list.html",
                            "children": []
                        },
                        {
                            "path": "/5-2",
                            "title": "会员统计报表",
                            "linkUrl": "report_member.html",
                            "children": []
                        },
                        {
                            "path": "/5-3",
                            "title": "套餐预约统计报表",
                            "linkUrl": "report_setmeal.html",
                            "children": []
                        },
                        {
                            "path": "/5-4",
                            "title": "运营数据统计报表",
                            "linkUrl": "report_business.html",
                            "children": []
                        },
                        {
                            "path": "/5-5",
                            "title": "会员性别统计报表",
                            "linkUrl":"report_sex.html",
                            "children":[]
                        },
                        {
                            "path": "/5-6",
                            "title": "会员年龄统计报表",
                            "linkUrl":"report_age.html",
                            "children":[]
                        }
                    ]
                }
            ],
            username: '',
            quanxian:[]
        },
        created() {
            axios.get("/user/getUserName.do").then(response=>{
                if (response.data.flag){
                    this.username= response.data.data.username;
                    this.menuList=response.data.data.byUsername2;
                    this.UserImg = "http://pugj835s3.bkt.clouddn.com/"+response.data.data.users.userImg;
                }
            });
            axios.get("/user/getUserRole.do").then(res=>{
                if (res.data.flag){
                    this.quanxian=res.data.data;
                }
            })
        },
        methods: {
            fun(e){
                console.log(e);
                axios.get("/user/changeUserRole.do?id="+e).then(res=>{
                    if (res.data.flag){
                        this.menuList=res.data.data;
                    }
                });
                axios.get("/user/changeUserName.do?id="+e).then(res=>{
                    if (res.data.flag){
                        this.quanxian=res.data.data;
                    }
                })
            },
            ///弹出修改密码框
            handleEdit() {

                this.formData = {};

                axios.get("/user/getUserName.do").then(response => {
                    if (response.data.flag) {
                        this.formData.username = response.data.data.username;

                        this.dialogFormVisibleEditPassword = true;
                    }
                });
            },

            //修改密码
            edit() {

                axios.post("/user/editPassword.do", this.formData).then(response => {

                    this.$message({
                        message: response.data.message,
                        type: response.data.flag ? 'success' : 'error'
                    });
                    //新增成功, 关闭dialog, 查询展示
                    if (response.data.flag) {
                        this.dialogFormVisibleEditPassword = false;
                        window.location.href = "/logout.do";
                    }
                });
            },
            //上传图片之前执行
            beforeAvatarUpload(file) {
                const isJPG = file.type === 'image/jpeg';
                const isLt2M = file.size / 1024 / 1024 < 2;
                if (!isJPG) {
                    this.$message.error('上传头像图片只能是 JPG 格式!');
                }
                if (!isLt2M) {
                    this.$message.error('上传头像图片大小不能超过 2MB!');
                }
                return isJPG && isLt2M;
            },

            //文件上传成功后的钩子，response为服务端返回的值，file为当前上传的文件封装成的js对象
            handleAvatarSuccess(response, file) {
                //{"data":文件名,"flag":true,"message":"文件上传成功"}
                if (response.flag){
                    //进行绑定显示,
                    this.UserImg = "http://pugj835s3.bkt.clouddn.com/"+response.data;  //UUID.jsp
                    //进行绑定, 最终保存到数据库(最终把formData提交, 包含了图片, 数据库里面只保存文件名)
                    this.formData.UserImg = response.data;
                }else{
                    this.$message.error(response.message);
                }
            },
        }
    });
    $(function () {
        var wd = 200;
        $(".el-main").css('width', $('body').width() - wd + 'px');
    });
</script>
</html>
